package geneComponent;

import java.util.LinkedList;
import java.util.List;

import base.Parameter;
import geneComponent.Node;

public abstract class Function extends Node {

    public Function(Parameter parameters) {
    	super(parameters);
    }

    public void operation() {
    	
    if(!this.isTerminal()){
    	List<Double> results = new LinkedList<Double>();

		for (Node node : branches) {
			if (!node.isTerminal()){
				((Function) node).operation();
			}
				results.add(node.getResult());
		}
		
		calc(results);
		setResult(results.get(0));
    	}
    }

    public abstract void calc(List<Double> results);
}

